﻿using ScFramework.Core;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public static class TranslationTool
{
    static Dictionary<string, string> nameDIC = null;
    public static string GetChinese(string english)
    {
        if (nameDIC == null)
        {
            Init();
        }
        //   Debug.LogError(english);
        if (nameDIC.ContainsKey(english))
        {
            return nameDIC[english];
        }
        else
        {
            Debug.LogError(english + "未找到");
            return default;
        }
    }
    static void Init()
    {
        var key1 = DataUtil.Table.CollectKey1("Dictionary");
        var key2 = DataUtil.Table.CollectKey2("Dictionary");
        nameDIC = new Dictionary<string, string>();
        for(int i = 0; i < key1.Count; i++)
        {
            string English=DataUtil.Table.GetString("Dictionary", key1[i], key2[0]);
            string Chinese= DataUtil.Table.GetString("Dictionary", key1[i], key2[1]);
            if (nameDIC.ContainsKey(English))
            {
                Debug.Log(English + "key重复");
            }
            else
            {
            nameDIC.Add(English, Chinese);

            }
        }
    }
    
}
